﻿package mortal.game.control
{
    import Framework.MQ.*;
    import Message.BroadCast.*;
    import Message.Command.*;
    import Message.DB.Tables.*;
    import Message.Game.*;
    import Message.Public.*;
    import com.gengine.core.*;
    import com.gengine.core.frame.*;
    import com.gengine.debug.*;
    import com.gengine.global.*;
    import com.gengine.resource.core.*;
    import com.greensock.*;
    import extend.language.*;
    import extend.php.*;
    import flash.events.*;
    import flash.geom.*;
    import flash.utils.*;
    import frEngine.event.*;
    import mortal.common.tools.*;
    import mortal.component.gconst.*;
    import mortal.game.*;
    import mortal.game.cache.*;
    import mortal.game.control.subControl.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.manager.mouse.*;
    import mortal.game.manager.window3d.*;
    import mortal.game.model.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.scene3D.*;
    import mortal.game.scene3D.ai.*;
    import mortal.game.scene3D.events.*;
    import mortal.game.scene3D.layer3D.utils.*;
    import mortal.game.scene3D.map3D.*;
    import mortal.game.scene3D.map3D.AstarAnyDirection.*;
    import mortal.game.scene3D.map3D.AstarAnyDirection.data.*;
    import mortal.game.scene3D.map3D.sceneInfo.*;
    import mortal.game.scene3D.map3D.util.*;
    import mortal.game.scene3D.model.data.*;
    import mortal.game.scene3D.player.entity.*;
    import mortal.game.scene3D.player.info.*;
    import mortal.game.scene3D.player.item.*;
    import mortal.game.scene3D.util.*;
    import mortal.game.utils.*;
    import mortal.game.view.guide.*;
    import mortal.game.view.skillProgress.*;
    import mortal.game.view.task.drama.operations.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class Scene3DController extends Controller
    {
        private var _dropItemAry:Array;
        private var _scene:GameScene3D;
        private var _lastClickScene:int;
        private var _tempMapPassTo:SPassTo;
        private var _lastMapPassTo:SPassTo;
        private var _roleDramaTween:TweenLite;
        private var _isInSky:Boolean = false;
        protected var skyTempx2d:int;
        protected var skyTempy2d:int;
        private const flySceneEffect:String = "Map_juchuan_yun01_wind";
        private var _flyTween:TweenLite;
        private var _lastPickupTime:int;

        public function Scene3DController()
        {
            this._dropItemAry = [];
            return;
        }// end function

        override protected function initView() : IView
        {
            this._scene = Game.scene;
            if (this._scene != null)
            {
                FrEventDispatcher.instance.proxyAddEventListener(this._scene, SceneEvent.INIT, this.onSceneInitHandler);
            }
            return null;
        }// end function

        override protected function initServer() : void
        {
            NetDispatcher.addCmdListener(ECmdBroadCast._ECmdBroadcastEntityInfo, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(ECmdBroadCast._ECmdBroadcastEntityInfos, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(ECmdBroadCast._ECmdBroadcastEntityMoveInfo, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicFightTargetPosReset, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(ECmdBroadCast._ECmdBroadcastEntityDiversion, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(ECmdBroadCast._ECmdBroadcastEntityConfusedPoint, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicRoleMoveTo, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicRoleConfusedPoint, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(ECmdBroadCast._ECmdBroadcastEntityLeftInfo, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(ECmdBroadCast._ECmdBroadcastEntityLeftInfos, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(ECmdBroadCast._ECmdBroadcastEntityAttributeUpdate, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(ECmdBroadCast._ECmdBroadcastEntityGuildIdUpdate, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(ECmdBroadCast._ECmdBroadcastEntityAttributeUpdates, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(ECmdBroadCast._ECmdBroadcastEntityGroupIdUpdate, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(ECmdBroadCast._ECmdBroadcastDropEntityInfo, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(ECmdBroadCast._ECmdBroadcastDropEntityInfos, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(ECmdBroadCast._ECmdBroadcastEntityFlashInfo, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicPetResetPoint, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(ECmdBroadCast._ECmdBroadcastEntityOwner, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(ECmdBroadCast._ECmdBroadcastEntityDoFight, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(ECmdBroadCast._ECmdBroadcastEntityDoFights, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(ECmdBroadCast._ECmdBroadcastEntityBeginFight, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(ECmdBroadCast._ECmdBroadcastEntityBeginCollect, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(ECmdBroadCast._ECmdBroadcastEntitySkillCast, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(ECmdBroadCast._ECmdBroadcastEntityToastUpdate, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(ECmdBroadCast._ECmdBroadcastEntityDrunkUpdate, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(ECmdBroadCast._ECmdBroadcastEntityMoraUpdate, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(ECmdBroadCast._ECmdBroadcastEntitySomersault, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(ECmdBroadCast._ECmdBroadcastEntityJump, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(ECmdBroadCast._ECmdBroadcastEntityJumpPoint, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicRoleSomersault, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicRoleJump, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicRoleJumpPoint, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicCrossPassPointMsg, this.onBroadCastHandler);
            NetDispatcher.addCmdListener(ECmdBroadCast._ECmdBroadcastMapSharp, this.mapSharpHandler);
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicMainCityStatues, this.onKingCityUpdateHandler);
            NetDispatcher.addCmdListener(ServerCommand.MapPointUpdate, this.onMapPointUpdate);
            Dispatcher.addEventListener(EventName.SceneSomersault, this.onSceneSomersault);
            Dispatcher.addEventListener(EventName.KeyPickDropItem, this.keyPickDropItemHandler);
            Dispatcher.addEventListener(EventName.PickDropItem, this.keyPickDropItemHandler);
            cache.role.roleEntityInfo.addEventListener(EntityInfoEventName.UpdateFightMode, this.onUpdateFightMode);
            NetDispatcher.addCmdListener(ServerCommand.TaskUpdate, this.onUpdateNPCStatus);
            NetDispatcher.addCmdListener(ServerCommand.TaskDoingAdd, this.onUpdateNPCStatus);
            NetDispatcher.addCmdListener(ServerCommand.TaskDoingDel, this.onUpdateNPCStatus);
            NetDispatcher.addCmdListener(ServerCommand.TaskCanGetAdd, this.onUpdateNPCStatus);
            NetDispatcher.addCmdListener(ServerCommand.TaskCanGetDel, this.onUpdateNPCStatus);
            NetDispatcher.addCmdListener(ServerCommand.TaskCanGetRecv, this.onUpdateNPCStatus);
            NetDispatcher.addCmdListener(ServerCommand.TaskDoingListRecv, this.onUpdateNPCStatus);
            return;
        }// end function

        private function mapSharpHandler(param1:MessageBlock) : void
        {
            var sceneUpdateForMapSharpHandler:Function;
            var mb:* = param1;
            sceneUpdateForMapSharpHandler = function (param1 = null) : void
            {
                var _loc_5:String = null;
                var _loc_6:Boolean = false;
                var _loc_7:SMapSharp = null;
                Dispatcher.removeEventListener(EventName.Scene_Update, sceneUpdateForMapSharpHandler);
                var _loc_2:* = mb.messageBase as SMapSharpInfo;
                var _loc_3:* = Game.sceneInfo;
                var _loc_4:* = Game.mapInfo.mapData;
                for (_loc_5 in _loc_2.sharpInfo)
                {
                    
                    _loc_6 = Boolean(_loc_2.sharpInfo[_loc_5]);
                    _loc_7 = _loc_3.sharpsMap[_loc_5];
                    if (_loc_7 == null)
                    {
                        MsgManager.showRollTipsMsg(Language.getString(20423) + _loc_5);
                        continue;
                    }
                    if (_loc_6)
                    {
                        AstarAnyDirection.addSharp(_loc_7, true, _loc_4);
                        ThingUtil.npcUtil.updateNpcIsAddToStage(parseInt(_loc_5), true, Game.mapInfo.mapId);
                        continue;
                    }
                    AstarAnyDirection.addSharp(_loc_7, false, _loc_4);
                    ThingUtil.npcUtil.updateNpcIsAddToStage(parseInt(_loc_5), false, Game.mapInfo.mapId);
                }
                if (_loc_2.bossSharpInfo != null)
                {
                    AstarAnyDirection.addBossSharp(_loc_2.bossSharpInfo);
                }
                return;
            }// end function
            ;
            if (!Game.scene.isInitialize)
            {
                Dispatcher.addEventListener(EventName.Scene_Update, sceneUpdateForMapSharpHandler);
            }
            else
            {
                this.sceneUpdateForMapSharpHandler();
            }
            return;
        }// end function

        private function onKingCityUpdateHandler(param1:MessageBlock) : void
        {
            var _loc_2:* = param1.messageBase as SMainCityStatues;
            SceneConfig.instance.getSceneInfo(80000).updateMainCityInfo(_loc_2);
            return;
        }// end function

        private function onBroadCastHandler(param1:MessageBlock) : void
        {
            var _loc_2:SEntityMoveInfo = null;
            var _loc_3:SPoint = null;
            var _loc_4:int = 0;
            var _loc_5:MovePlayer = null;
            var _loc_6:SEntityInfo = null;
            var _loc_7:EntityInfo = null;
            var _loc_8:SEntityId = null;
            var _loc_10:SFightTargetPosReset = null;
            var _loc_11:SPoint = null;
            var _loc_12:AstarTurnPoint = null;
            var _loc_13:SPoints = null;
            var _loc_14:SSeqEntityIdInfo = null;
            var _loc_15:SBeginFight = null;
            var _loc_16:int = 0;
            var _loc_17:SAttributeUpdate = null;
            var _loc_18:SDoFight = null;
            var _loc_19:SDoFights = null;
            var _loc_20:SSkillCast = null;
            var _loc_21:TSkill = null;
            var _loc_22:SEntityMoveInfo = null;
            var _loc_23:PetPlayer = null;
            var _loc_24:SCrossPassPointMsg = null;
            var _loc_9:String = "";
            switch(param1.messageHead.command)
            {
                case ECmdBroadCast._ECmdBroadcastEntityInfo:
                {
                    Log.printMsg(LogType.other, "ECmdBroadCast._ECmdBroadcastEntityInfo");
                    if (DebugConst.isOutPutAddEntity)
                    {
                        Log.debug("ECmdBroadCast._ECmdBroadcastEntityInfo");
                        Log.debug((param1.messageBase as SEntityInfo).entityId.id);
                    }
                    cache.entity.addEntity(param1.messageBase as SEntityInfo);
                    break;
                }
                case ECmdBroadCast._ECmdBroadcastEntityInfos:
                {
                    Log.printMsg(LogType.other, "ECmdBroadCast._ECmdBroadcastEntityInfos");
                    if (DebugConst.isOutPutAddEntity)
                    {
                        Log.debug("ECmdBroadCast._ECmdBroadcastEntityInfos", (param1.messageBase as SSeqEntityInfo).entityInfos.length);
                        for each (_loc_6 in (param1.messageBase as SSeqEntityInfo).entityInfos)
                        {
                            
                            Log.debug(_loc_6.entityId.id);
                        }
                    }
                    cache.entity.addEntitys(param1.messageBase as SSeqEntityInfo);
                    break;
                }
                case EPublicCommand._ECmdPublicFightTargetPosReset:
                {
                    _loc_10 = param1.messageBase as SFightTargetPosReset;
                    _loc_11 = _loc_10.sPoint;
                    _loc_12 = new AstarTurnPoint();
                    _loc_12.setValue(_loc_11.x, _loc_11.y);
                    _loc_5 = ThingUtil.entityUtil.getEntity(_loc_10.sEntityId) as MovePlayer;
                    if (_loc_5)
                    {
                        _loc_5.walking([_loc_12]);
                    }
                    break;
                }
                case ECmdBroadCast._ECmdBroadcastEntityMoveInfo:
                {
                    _loc_2 = param1.messageBase as SEntityMoveInfo;
                    this.moveEntity(_loc_2, _loc_2.points);
                    if (DebugConst.isOutPutMove)
                    {
                        Log.debug("ECmdBroadCast._ECmdBroadcastEntityMoveInfo", _loc_2.entityId.id, getTimer());
                        _loc_9 = "";
                        _loc_4 = 0;
                        while (_loc_4 < _loc_2.points.length)
                        {
                            
                            _loc_3 = _loc_2.points[_loc_4] as SPoint;
                            _loc_9 = _loc_9 + ("(" + _loc_3.x + "," + _loc_3.y + ")");
                            _loc_4++;
                        }
                        Log.debug(_loc_9);
                    }
                    break;
                }
                case ECmdBroadCast._ECmdBroadcastEntityDiversion:
                case ECmdBroadCast._ECmdBroadcastEntityConfusedPoint:
                {
                    _loc_2 = param1.messageBase as SEntityMoveInfo;
                    this.diversionEntity(_loc_2, _loc_2.points);
                    if (DebugConst.isOutPutMove)
                    {
                        Log.debug("ECmdBroadCast._ECmdBroadcastEntityDiversion", _loc_2.entityId.id, getTimer());
                        _loc_9 = "";
                        _loc_4 = 0;
                        while (_loc_4 < _loc_2.points.length)
                        {
                            
                            _loc_3 = _loc_2.points[_loc_4] as SPoint;
                            _loc_9 = _loc_9 + ("(" + _loc_3.x + "," + _loc_3.y + ")");
                            _loc_4++;
                        }
                        Log.debug(_loc_9);
                    }
                    break;
                }
                case EPublicCommand._ECmdPublicRoleMoveTo:
                case EPublicCommand._ECmdPublicRoleConfusedPoint:
                {
                    _loc_13 = param1.messageBase as SPoints;
                    this.roleMoveTo(_loc_13);
                    if (DebugConst.isOutPutMove)
                    {
                        Log.debug("EPublicCommand._ECmdPublicRoleMoveTo");
                        _loc_4 = 0;
                        while (_loc_4 < _loc_13.points.length)
                        {
                            
                            _loc_3 = _loc_13.points[_loc_4] as SPoint;
                            Log.debug(_loc_3.x, _loc_3.y);
                            _loc_4++;
                        }
                    }
                    break;
                }
                case ECmdBroadCast._ECmdBroadcastDropEntityInfo:
                {
                    this.dropItem(param1.messageBase as SDropEntityInfo);
                    break;
                }
                case ECmdBroadCast._ECmdBroadcastDropEntityInfos:
                {
                    this.dropItems(param1.messageBase as SSeqDropEntityInfo);
                    break;
                }
                case ECmdBroadCast._ECmdBroadcastEntityLeftInfo:
                {
                    if (DebugConst.isOutPutAddEntity)
                    {
                        Log.debug("ECmdBroadCast._ECmdBroadcastEntityLeftInfo");
                        Log.debug((param1.messageBase as SEntityId).id);
                    }
                    cache.entity.removeEntity(param1.messageBase as SEntityId);
                    this.removeEntity(param1.messageBase as SEntityId);
                    break;
                }
                case ECmdBroadCast._ECmdBroadcastEntityLeftInfos:
                {
                    if (DebugConst.isOutPutAddEntity)
                    {
                        Log.debug("ECmdBroadCast._ECmdBroadcastEntityLeftInfos", (param1.messageBase as SSeqEntityIdInfo).entityIds.length);
                        for each (_loc_8 in (param1.messageBase as SSeqEntityIdInfo).entityIds)
                        {
                            
                            Log.debug(_loc_8.id);
                        }
                    }
                    _loc_14 = param1.messageBase as SSeqEntityIdInfo;
                    cache.entity.removeEntitys(_loc_14.entityIds);
                    ThingUtil.entityUtil.removeEntitys(_loc_14.entityIds);
                    break;
                }
                case ECmdBroadCast._ECmdBroadcastEntityAttributeUpdate:
                {
                    if (param1.messageBase is SEntityUpdate)
                    {
                        cache.entity.updateAttribute(param1.messageBase as SEntityUpdate);
                    }
                    break;
                }
                case ECmdBroadCast._ECmdBroadcastEntityAttributeUpdates:
                {
                    cache.entity.updateAttributes(param1.messageBase as SSeqEntityUpdate);
                    break;
                }
                case ECmdBroadCast._ECmdBroadcastEntityGroupIdUpdate:
                {
                    this.updateEntityGroupId(param1.messageBase as SBroadcastGroupIdUpdate);
                    break;
                }
                case ECmdBroadCast._ECmdBroadcastEntityBeginFight:
                {
                    _loc_15 = param1.messageBase as SBeginFight;
                    _loc_16 = 0;
                    for each (_loc_17 in _loc_15.propertyUpdates)
                    {
                        
                        if (_loc_17.attribute.__value == EEntityAttribute._EAttributeAttackSkill)
                        {
                            _loc_16 = _loc_17.value;
                        }
                    }
                    if (this._scene)
                    {
                        if (_loc_15.msgEx == null)
                        {
                            ThingUtil.fightUtil.beginFight(_loc_15);
                        }
                    }
                    break;
                }
                case ECmdBroadCast._ECmdBroadcastEntityDoFight:
                {
                    if (this._scene)
                    {
                        _loc_18 = param1.messageBase as SDoFight;
                        if (_loc_18.msgEx == null)
                        {
                            ThingUtil.fightUtil.doFight(_loc_18);
                        }
                    }
                    break;
                }
                case ECmdBroadCast._ECmdBroadcastEntityDoFights:
                {
                    if (this._scene)
                    {
                        _loc_19 = param1.messageBase as SDoFights;
                        ThingUtil.fightUtil.doFights(_loc_19);
                    }
                    break;
                }
                case ECmdBroadCast._ECmdBroadcastEntitySkillCast:
                {
                    _loc_20 = param1.messageBase as SSkillCast;
                    Log.debug("skillCast" + _loc_20.count);
                    if (EntityUtil.equal(_loc_20.entityId, cache.role.roleEntityInfo.entityInfo.entityId))
                    {
                        _loc_21 = SkillConfig.instance.getInfoById(_loc_20.skillId);
                        if (_loc_21.type != ESkillType._ESKillTypeTornado)
                        {
                            SkillProgressView.instance.updateCount(_loc_21, _loc_20.count);
                        }
                        if (_loc_20.toEntityIds.length)
                        {
                            cache.role.roleEntityInfo.entityInfo.toEntityId = _loc_20.toEntityIds[0];
                        }
                    }
                    ThingUtil.fightUtil.skillCast(_loc_20);
                    break;
                }
                case ECmdBroadCast._ECmdBroadcastEntityOwner:
                {
                    break;
                }
                case ECmdBroadCast._ECmdBroadcastEntityBeginCollect:
                {
                    break;
                }
                case ECmdBroadCast._ECmdBroadcastEntityFlashInfo:
                {
                    _loc_22 = param1.messageBase as SEntityMoveInfo;
                    ThingUtil.entityUtil.refreshPoint(_loc_22.entityId, _loc_22.points);
                    if (_loc_7)
                    {
                        _loc_7 = cache.entity.getEntityInfoById(_loc_22.entityId);
                        _loc_7.entityInfo.points = _loc_22.points;
                    }
                    break;
                }
                case EPublicCommand._ECmdPublicPetResetPoint:
                {
                    _loc_3 = param1.messageBase as SPoint;
                    _loc_23 = ThingUtil.entityUtil.getSelfPetEntity();
                    if (_loc_23)
                    {
                        _loc_23.stopMove();
                        _loc_23.setPixlePoint(_loc_3.x, _loc_3.y);
                    }
                    break;
                }
                case ECmdBroadCast._ECmdBroadcastEntitySomersault:
                {
                    _loc_2 = param1.messageBase as SEntityMoveInfo;
                    _loc_3 = _loc_2.points[1];
                    _loc_5 = ThingUtil.entityUtil.getEntity(_loc_2.entityId) as MovePlayer;
                    if (_loc_5)
                    {
                        JumpUtil.somersault(_loc_5, _loc_3.x, _loc_3.y);
                    }
                    else
                    {
                        _loc_7 = cache.entity.getEntityInfoById(_loc_2.entityId);
                        if (_loc_7)
                        {
                            _loc_7.entityInfo.points = _loc_2.points;
                        }
                    }
                    break;
                }
                case EPublicCommand._ECmdPublicRoleSomersault:
                {
                    Cache.instance.cd.somersaultCd.startCoolDown();
                    _loc_3 = (param1.messageBase as SPoints).points[1];
                    Dispatcher.dispatchEvent(new DataEvent(EventName.RoleJump));
                    JumpUtil.somersault(RolePlayer.instance, _loc_3.x, _loc_3.y);
                    break;
                }
                case ECmdBroadCast._ECmdBroadcastEntityJump:
                case ECmdBroadCast._ECmdBroadcastEntityJumpPoint:
                {
                    _loc_2 = param1.messageBase as SEntityMoveInfo;
                    _loc_5 = ThingUtil.entityUtil.getEntity(_loc_2.entityId) as MovePlayer;
                    if (_loc_5)
                    {
                        JumpUtil.jumpPoints(_loc_5, _loc_2.points);
                    }
                    else
                    {
                        _loc_7 = cache.entity.getEntityInfoById(_loc_2.entityId);
                        if (_loc_7)
                        {
                            _loc_7.entityInfo.points = _loc_2.points;
                        }
                    }
                    break;
                }
                case EPublicCommand._ECmdPublicRoleJump:
                case EPublicCommand._ECmdPublicRoleJumpPoint:
                {
                    JumpUtil.jumpPoints(RolePlayer.instance, (param1.messageBase as SPoints).points);
                    break;
                }
                case ECmdBroadCast._ECmdBroadcastEntityStop:
                {
                    this.stopEntityMove(param1.messageBase as SEntityId);
                    break;
                }
                case ECmdBroadCast._ECmdBroadcastEntityGuildIdUpdate:
                {
                    this.updateEntityGuildId(param1.messageBase as SGuildIdUpdate);
                    break;
                }
                case EPublicCommand._ECmdPublicCrossPassPointMsg:
                {
                    _loc_24 = param1.messageBase as SCrossPassPointMsg;
                    Cache.instance.passCrossCache.pass = _loc_24;
                    ThingUtil.isMoveChange = true;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        private function updateEntityGroupId(param1:SBroadcastGroupIdUpdate) : void
        {
            if (EntityUtil.equal(param1.updateEntityId, cache.role.roleEntityInfo.entityInfo.entityId))
            {
                cache.role.roleEntityInfo.updateGroupId(param1.groupId);
                ThingUtil.isNameChange = true;
            }
            var _loc_2:* = cache.entity.getEntityInfoById(param1.updateEntityId);
            if (_loc_2)
            {
                _loc_2.updateGroupId(param1.groupId);
            }
            return;
        }// end function

        public function moveEntity(param1:SEntityMoveInfo, param2:Array) : void
        {
            var _loc_3:Array = null;
            var _loc_4:SPoint = null;
            var _loc_5:int = 0;
            var _loc_6:Boolean = false;
            var _loc_7:AstarTurnPoint = null;
            var _loc_8:EntityInfo = null;
            if (this._scene)
            {
                _loc_3 = [];
                _loc_5 = 0;
                while (_loc_5 < param2.length)
                {
                    
                    _loc_4 = param2[_loc_5];
                    _loc_7 = new AstarTurnPoint();
                    _loc_7.setValue(_loc_4.x, _loc_4.y);
                    _loc_3.push(_loc_7);
                    _loc_5++;
                }
                _loc_6 = ThingUtil.entityUtil.moveEntity(param1, _loc_3);
                if (!_loc_6)
                {
                    _loc_8 = cache.entity.getEntityInfoById(param1.entityId);
                    if (_loc_8)
                    {
                        _loc_8.entityInfo.points = [_loc_4];
                    }
                }
            }
            return;
        }// end function

        public function diversionEntity(param1:SEntityMoveInfo, param2:Array) : void
        {
            var _loc_3:Array = null;
            var _loc_4:SPoint = null;
            var _loc_5:int = 0;
            var _loc_6:Boolean = false;
            var _loc_7:AstarTurnPoint = null;
            var _loc_8:EntityInfo = null;
            if (this._scene)
            {
                _loc_3 = [];
                _loc_5 = 0;
                while (_loc_5 < param2.length)
                {
                    
                    _loc_4 = param2[_loc_5];
                    _loc_7 = new AstarTurnPoint();
                    _loc_7.setValue(_loc_4.x, _loc_4.y);
                    _loc_3.push(_loc_7);
                    _loc_5++;
                }
                _loc_6 = ThingUtil.entityUtil.diversionEntity(param1, _loc_3);
                if (!_loc_6)
                {
                    _loc_8 = cache.entity.getEntityInfoById(param1.entityId);
                    if (_loc_8)
                    {
                        _loc_8.entityInfo.points = [_loc_4];
                    }
                }
            }
            return;
        }// end function

        public function roleMoveTo(param1:SPoints) : void
        {
            var _loc_2:Array = null;
            var _loc_3:SPoint = null;
            var _loc_4:int = 0;
            var _loc_5:AstarTurnPoint = null;
            if (this._scene)
            {
                _loc_2 = [];
                _loc_4 = 0;
                while (_loc_4 < param1.points.length)
                {
                    
                    _loc_3 = param1.points[_loc_4];
                    _loc_5 = new AstarTurnPoint();
                    _loc_5.setValue(_loc_3.x, _loc_3.y);
                    _loc_2.push(_loc_5);
                    _loc_4++;
                }
                RolePlayer.instance.inServerMove = true;
                RolePlayer.instance.walking(_loc_2);
            }
            return;
        }// end function

        private function onSceneInitHandler(event:Event) : void
        {
            var _loc_2:SPassTo = null;
            if (this._dropItemAry.length)
            {
                ThingUtil.dropItemUtil.addDropItems(this._dropItemAry);
                this._dropItemAry.length = 0;
            }
            Global.stage.addEventListener(MouseEvent.MOUSE_DOWN, this.onSceneMouseClick);
            FrEventDispatcher.instance.proxyAddEventListener(RolePlayer.instance, PlayerEvent.GIRD_WALK_START, this.onGirdWalkStartHandler);
            FrEventDispatcher.instance.proxyAddEventListener(RolePlayer.instance, PlayerEvent.ServerPoint, this.onServerPointsHandler);
            FrEventDispatcher.instance.proxyAddEventListener(RolePlayer.instance, PlayerEvent.WALK_END, this.onWalkEndHandler);
            Dispatcher.addEventListener(EventName.SelfPetCopyMove, this.onSelfPetCopyMove);
            ThingUtil.isMoveChange = true;
            Dispatcher.dispatchEvent(new DataEvent(EventName.Scene_Update, Game.sceneInfo));
            if (this._tempMapPassTo)
            {
                _loc_2 = this._tempMapPassTo;
                this._tempMapPassTo = null;
                Log.debug("doTempPass", _loc_2.mapId, _loc_2.toPoint.x, _loc_2.toPoint.y);
                this.mapPassTo(_loc_2);
            }
            this.onUpdateNPCStatus();
            MouseLongPress.instance.reset(300);
            MouseLongPress.instance.setIntervalAction(1, this.moveRoleTo);
            MouseRightLongPress.instance.reset(300);
            return;
        }// end function

        private function moveRoleTo() : void
        {
            if (GameController.shortcut.keyProcessor.isWorking() || !BuffUtil.isCanRoleWalk())
            {
                return;
            }
            if (RolePlayer.instance.isInSpasticity || RolePlayer.instance.isJumping)
            {
                return;
            }
            if (GameController.copy.winePartyCopy.isStartMora)
            {
                return;
            }
            if (GameController.arena.isInCountDown)
            {
                return;
            }
            if (GameController.copy.heroArenaCopy.isInCountDown)
            {
                return;
            }
            var _loc_1:* = Scene3DUtil.getSceneMousePostion(Global.stage.mouseX, Global.stage.mouseY, true);
            Scene3DClickProcessor.gotoPoint(_loc_1, true, -1, false);
            return;
        }// end function

        private function onGirdWalkStartHandler(event:Event) : void
        {
            if (RolePlayer.instance.isCanControlWalk)
            {
                GameProxy.sceneProxy.move(RolePlayer.instance.serverPoints);
            }
            return;
        }// end function

        private function onServerPointsHandler(event:Event) : void
        {
            if (RolePlayer.instance.isCanControlWalk)
            {
                GameProxy.sceneProxy.diversion(RolePlayer.instance.serverPoints);
            }
            return;
        }// end function

        private function onSelfPetCopyMove(event:DataEvent) : void
        {
            GameProxy.sceneProxy.moveSelfPet([event.data]);
            return;
        }// end function

        private function onWalkEndHandler(event:Event) : void
        {
            GameProxy.sceneProxy.clearLastPoint();
            return;
        }// end function

        private function onSceneMouseClick(event:MouseEvent) : void
        {
            if (!this._scene.getMouseEnabled() || Rect3DManager.instance.isRectContains(event.stageX, event.stageY))
            {
                return;
            }
            Scene3DClickProcessor.instance.work(event);
            return;
        }// end function

        public function removeEntity(param1:SEntityId) : void
        {
            if (this._scene)
            {
                ThingUtil.entityUtil.removeEntity(param1);
            }
            return;
        }// end function

        private function dropItem(param1:SDropEntityInfo) : void
        {
            if (this._scene && this._scene.isInitialize)
            {
                ThingUtil.dropItemUtil.addDropItem(param1);
                if (cache.role.roleInfo.level < 60)
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.DropItem));
                }
            }
            else
            {
                this._dropItemAry.push(param1);
            }
            return;
        }// end function

        private function dropItems(param1:SSeqDropEntityInfo) : void
        {
            if (this._scene && this._scene.isInitialize)
            {
                ThingUtil.dropItemUtil.addDropItems(param1.entityInfos);
                if (cache.role.roleInfo.level < 60)
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.DropItem));
                }
            }
            else
            {
                this._dropItemAry = this._dropItemAry.concat(param1.entityInfos);
            }
            return;
        }// end function

        private function onMapPointUpdate(param1:SPassTo) : void
        {
            this._lastMapPassTo = param1;
            Log.debug("onMapPointUpdate", param1.mapId, param1.toPoint.x, param1.toPoint.y);
            if (this._scene == null || this._scene.isInitialize == false)
            {
                if (param1.mapId == MapFileUtil.mapID)
                {
                    this._tempMapPassTo = param1;
                    Log.debug("setTempPass", param1.mapId, param1.toPoint.x, param1.toPoint.y);
                    return;
                }
                MapLoader.instance.stop();
            }
            this.mapPassTo(param1);
            return;
        }// end function

        private function mapPassTo(param1:SPassTo) : void
        {
            GameManager.instance.updateLastOperTime();
            Log.debug("mapPassTo", param1.mapId, param1.toPoint.x, param1.toPoint.y);
            RolePlayer.instance.setAction(ActionType.Stand, ActionName.Stand, true);
            SkillProgressView.instance.updateCount(null, -1);
            RolePlayer.instance.isInLeading = false;
            if (param1.passToId == 80 || param1.mapId != MapFileUtil.mapID)
            {
                if (ThingUtil.selectEntity != null)
                {
                    ThingUtil.selectEntity.selected = false;
                }
                Dispatcher.dispatchEvent(new DataEvent(EventName.LeaveScene, MapFileUtil.mapID));
                this._scene.clearAll();
                if (this._roleDramaTween)
                {
                    this._roleDramaTween.kill();
                    this._roleDramaTween = null;
                }
                PHPSender.setToPHPMapFrame(MapFileUtil.mapID, FrameUtil.driveInfo, 1);
                MapFrameUtil.changeMapId(param1.mapId);
                MapFileUtil.mapID = param1.mapId;
                if (this.sceneScale != 1 && !this._isInSky && !cache.role.roleEntityInfo.isInFly)
                {
                    this.sceneScale = 1;
                }
                GameMapUtil.curMapState.initMapId(param1.mapId);
                this._scene.setPlayerPoint(param1.mapId, param1.toPoint.x, param1.toPoint.y);
                Dispatcher.dispatchEvent(new DataEvent(EventName.ChangeScene));
            }
            else
            {
                RolePlayer.instance.setPixlePoint(param1.toPoint.x, param1.toPoint.y);
                RolePlayer.instance.walkBreak();
                Dispatcher.dispatchEvent(new DataEvent(EventName.ChangePosition));
                ThingUtil.isMoveChange = true;
                Dispatcher.dispatchEvent(new DataEvent(EventName.SkillFlashInto));
            }
            return;
        }// end function

        public function roleBeBlowFly(param1:int, param2:int, param3:int, param4:int, param5:Function = null) : void
        {
            var x1:* = param1;
            var y1:* = param2;
            var x2:* = param3;
            var y2:* = param4;
            var callBack:* = param5;
            var roleDropCliff:* = function (param1:int, param2:int) : void
            {
                var x:* = param1;
                var y:* = param2;
                Game.scene.lockSceen();
                _roleDramaTween = TweenLite.to(RolePlayer.instance, 4, {x2d:x, y2d:y, scaleX:0, scaleY:0, scaleZ:0, onComplete:function () : void
                {
                    if (callBack != null)
                    {
                        TaskDramaOpBlackScreen.instance.call(new TTaskDrama());
                        setTimeout(TaskDramaOpBlackScreen.instance.cancel, 1000, new TTaskDrama());
                        callBack.call();
                    }
                    return;
                }// end function
                });
                return;
            }// end function
            ;
            RolePlayer.instance.setHideHead(true);
            if (cache.role.roleEntityInfo.entityInfo.mountCode)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.MountRide));
            }
            Game.scene.setMouseEnabled(false);
            AIManager.cancelAll();
            TweenLite.to(this, 0.5, {sceneScaleNoRoleY:0.7});
            this._roleDramaTween = TweenLite.to(RolePlayer.instance, 0.5, {x2d:x1, y2d:y1, onStart:function () : void
            {
                RolePlayer.instance.setAction(ActionType.Death, ActionName.Death);
                return;
            }// end function
            , onUpdate:function () : void
            {
                RolePlayer.instance.setPixlePoint(RolePlayer.instance.x2d, RolePlayer.instance.y2d);
                return;
            }// end function
            , onComplete:function () : void
            {
                roleDropCliff(x2, y2);
                return;
            }// end function
            });
            return;
        }// end function

        public function cancelRoleCliff() : void
        {
            RolePlayer.instance.setHideHead(false);
            Game.scene.setMouseEnabled(true);
            Game.scene.unLockSceen();
            RolePlayer.instance.setPixlePoint(RolePlayer.instance.x2d, RolePlayer.instance.y2d);
            RolePlayer.instance.scaleX = 1;
            RolePlayer.instance.scaleY = 1;
            RolePlayer.instance.scaleZ = 1;
            this.sceneScale = 1;
            return;
        }// end function

        public function get isInSky() : Boolean
        {
            return this._isInSky;
        }// end function

        public function RoleInSky() : void
        {
            this._isInSky = true;
            AIManager.cancelAll();
            RolePlayer.instance.setAction(ActionType.Death, ActionName.Death);
            RolePlayer.instance.setHideHead(true);
            Game.scene.setMouseEnabled(false);
            StreamManager.defaultFrameLoadNum = 4;
            this.sceneScaleNoRoleY = 0.4;
            var _loc_1:* = SceneRange.display.height / 620;
            RolePlayer.instance.y = 1050 * _loc_1;
            RolePlayer.instance.openShadow = false;
            if (cache.role.roleEntityInfo.entityInfo.mountCode)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.MountRide));
            }
            return;
        }// end function

        public function RoleSlowDown() : void
        {
            if (cache.role.roleEntityInfo.entityInfo.mountCode)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.MountRide));
            }
            Game.scene.lockSceen();
            TweenLite.to(RolePlayer.instance, 1, {y:0, scaleX:1, scaleY:1, scaleZ:1, onStart:function () : void
            {
                RolePlayer.instance.setAction(ActionType.Death, ActionName.Death);
                return;
            }// end function
            , onComplete:function () : void
            {
                RolePlayer.instance.openShadow = true;
                viewDown();
                return;
            }// end function
            });
            return;
        }// end function

        public function viewDown() : void
        {
            TweenLite.to(this, 2, {sceneScaleNoRole:1, onComplete:function () : void
            {
                _isInSky = false;
                Game.scene.unLockSceen();
                StreamManager.defaultFrameLoadNum = 1;
                Game.scene.setMouseEnabled(true);
                RolePlayer.instance.setHideHead(false);
                RolePlayer.instance.setAction(ActionType.Stand, ActionName.Stand);
                return;
            }// end function
            });
            return;
        }// end function

        public function set sceneScaleNoRole(param1:Number) : void
        {
            Game.scene.sceneScale = param1;
            var _loc_2:* = 1 / param1;
            Game.scene.scrollRect = SceneRange.display;
            return;
        }// end function

        public function get sceneScaleNoRole() : Number
        {
            return Game.scene.sceneScale;
        }// end function

        public function set sceneScaleNoRoleY(param1:Number) : void
        {
            Game.scene.sceneScale = param1;
            var _loc_2:* = 1 / param1;
            RolePlayer.instance.scaleX = _loc_2;
            RolePlayer.instance.scaleY = _loc_2;
            RolePlayer.instance.scaleZ = _loc_2;
            Game.scene.scrollRect = SceneRange.display;
            return;
        }// end function

        public function get sceneScaleNoRoleY() : Number
        {
            return Game.scene.sceneScale;
        }// end function

        public function set sceneScale(param1:Number) : void
        {
            Game.scene.sceneScale = param1;
            var _loc_2:* = 1 / param1;
            RolePlayer.instance.scaleX = _loc_2;
            RolePlayer.instance.scaleY = _loc_2;
            RolePlayer.instance.scaleZ = _loc_2;
            RolePlayer.instance.y = this.getPlayerYByScale(_loc_2);
            Game.scene.scrollRect = SceneRange.display;
            return;
        }// end function

        private function getPlayerYByScale(param1:Number) : Number
        {
            var _loc_3:Number = NaN;
            var _loc_2:* = SceneRange.display.height / 620;
            if (param1 > 1.5)
            {
                _loc_3 = 150 + (param1 - 1.5) * 100;
            }
            else if (param1 > 1)
            {
                _loc_3 = (param1 - 1) * 300;
            }
            else if (param1 > 0.5)
            {
                _loc_3 = (1 / param1 - 1) * -250;
            }
            else
            {
                _loc_3 = -400 + (1 / param1 - 2) * -150;
            }
            return _loc_3 * _loc_2;
        }// end function

        public function get sceneScale() : Number
        {
            return Game.scene.sceneScale;
        }// end function

        public function flyToSky(param1:int = 2, param2:Number = 1.5, param3:Boolean = false) : void
        {
            Game.scene.changeSceneEffect(this.flySceneEffect);
            this._isInSky = true;
            RolePlayer.instance.killFlyTween();
            RolePlayer.instance.setHideHead(true);
            StreamManager.defaultFrameLoadNum = 4;
            if (this._flyTween)
            {
                this._flyTween.kill();
                this._flyTween = null;
            }
            if (param1 > 0)
            {
                if (param3)
                {
                    this._flyTween = TweenLite.to(this, param1, {sceneScale:1 / param2});
                }
                else
                {
                    this._flyTween = TweenLite.to(this, param1, {sceneScaleNoRole:1 / param2});
                }
            }
            else if (param3)
            {
                this.sceneScale = 1 / param2;
            }
            else
            {
                this.sceneScaleNoRole = 1 / param2;
            }
            return;
        }// end function

        public function land(param1:int = 2, param2:Boolean = false, param3:Function = null) : void
        {
            var landCompl:Function;
            var time:* = param1;
            var isScaleRole:* = param2;
            var onCompl:* = param3;
            landCompl = function () : void
            {
                _isInSky = false;
                StreamManager.defaultFrameLoadNum = 1;
                RolePlayer.instance.setHideHead(false);
                RolePlayer.instance.setAction(ActionType.Stand, ActionName.Stand);
                Game.scene.changeSceneEffect(null);
                if (onCompl != null)
                {
                    onCompl.call();
                }
                return;
            }// end function
            ;
            if (this._flyTween)
            {
                this._flyTween.kill();
                this._flyTween = null;
            }
            var vars:* = new Object();
            if (isScaleRole)
            {
                vars.sceneScale = 1;
            }
            else
            {
                vars.sceneScaleNoRole = 1;
            }
            vars.onComplete = landCompl;
            if (time > 0)
            {
                this._flyTween = TweenLite.to(this, time, vars);
            }
            else
            {
                if (isScaleRole)
                {
                    this.sceneScale = 1;
                }
                else
                {
                    this.sceneScaleNoRole = 1;
                }
                this.landCompl();
            }
            return;
        }// end function

        private function onSceneSomersault(event:DataEvent) : void
        {
            var _loc_2:* = event.data as Point;
            var _loc_3:* = new SPoint();
            _loc_3.x = _loc_2.x;
            _loc_3.y = _loc_2.y;
            RolePlayer.instance.stopMove();
            GameProxy.sceneProxy.somersault(_loc_3);
            return;
        }// end function

        private function keyPickDropItemHandler(event:DataEvent) : void
        {
            var entityId:SEntityId;
            var isSelfOnly:Boolean;
            var dropItemPlayer:ItemPlayer;
            var now:int;
            var isFull:Boolean;
            var item:SPlayerItem;
            var e:* = event;
            entityId = e.data as SEntityId;
            if (!entityId)
            {
                isSelfOnly = GameMapUtil.curMapState.isGuildBoss ? (false) : (true);
                dropItemPlayer = ThingUtil.dropItemUtil.getRandomDropItem(isSelfOnly);
                if (dropItemPlayer)
                {
                    entityId = dropItemPlayer.dropEntityInfo.entityId;
                }
            }
            if (entityId)
            {
                var movedToPickup:* = function () : void
            {
                if (entityId == null)
                {
                    return;
                }
                GameProxy.sceneProxy.pickup(entityId, item);
                return;
            }// end function
            ;
                now = FrameManager.flashFrame.getTime();
                if (now - this._lastPickupTime < GameConst.PickUpTimeDistance)
                {
                    return;
                }
                this._lastPickupTime = now;
                if (dropItemPlayer == null)
                {
                    dropItemPlayer = ThingUtil.dropItemUtil.getDropItem(entityId);
                }
                isFull;
                if (dropItemPlayer != null)
                {
                    item = dropItemPlayer.dropEntityInfo.playerItems[0];
                    if (item != null)
                    {
                        isFull = Cache.instance.pack.backPackCache.isPackFull(item.itemCode, 1);
                        if (!isFull)
                        {
                            GuidePickupItemFly.instance.inCode(item.itemCode, dropItemPlayer);
                        }
                    }
                }
                if (isFull)
                {
                    MsgManager.showRollTipsMsg(Language.getString(20424));
                    return;
                }
                if (dropItemPlayer != null)
                {
                    AIManager.cancelAll();
                    AIManager.addMoveTo(new Point(dropItemPlayer.x2d, dropItemPlayer.y2d), GameConst.PickUpDistance);
                    AIManager.addCallback(movedToPickup);
                    AIManager.start();
                }
            }
            return;
        }// end function

        private function onUpdateFightMode(event:EntityInfoEvent) : void
        {
            ThingUtil.isNameChange = true;
            return;
        }// end function

        private function stopEntityMove(param1:SEntityId) : void
        {
            var _loc_2:* = ThingUtil.entityUtil.getEntity(param1) as MovePlayer;
            if (_loc_2)
            {
                _loc_2.stopMove();
            }
            return;
        }// end function

        private function updateEntityGuildId(param1:SGuildIdUpdate) : void
        {
            var _loc_2:* = cache.entity.getEntityInfoById(param1.updateEntityId);
            if (_loc_2)
            {
                _loc_2.updateGuildIdByEntityId(param1.guildId);
            }
            return;
        }// end function

        private function onUpdateNPCStatus(param1 = null) : void
        {
            var _loc_2:int = 0;
            var _loc_4:NPCInfo = null;
            var _loc_6:NPCPlayer = null;
            if (!Game.sceneInfo)
            {
                return;
            }
            var _loc_3:* = Game.sceneInfo.npcInfos.length;
            var _loc_5:Array = [];
            while (_loc_2 < _loc_3)
            {
                
                _loc_4 = Game.sceneInfo.npcInfos[_loc_2];
                if (_loc_4.tnpc)
                {
                    _loc_4.taskStatus = cache.npc.getNpcTaskStatus(_loc_4.snpc.npcId);
                    _loc_5.push(_loc_4);
                }
                _loc_6 = ThingUtil.npcUtil.getNpc(_loc_4.snpc.npcId);
                if (_loc_6 != null)
                {
                    _loc_6.updateStatus(_loc_4);
                }
                _loc_2++;
            }
            return;
        }// end function

    }
}
